﻿/*
{
"状态":1,
"名称":"获取-角色权限信息",
"作者":"陈泽椿",
"创建时间":"2018-06-30",
"功能":"获取-角色权限信息",
"log": [
	{"date":"06-01" , "dev" :"hzhh" , "content" : ""}
]
}
*/

declare @sql varchar(max)
declare @where varchar(max)
declare @type varchar(max)
declare @role_key int
declare @power_tree_key int 

set @role_key = '{role_key}'
set @power_tree_key='{power_tree_key}'
set @type = '{type}'
set @where = ''

if isnull(@power_tree_key,0)<>0
begin
	set @where += ' and power_tree_key='+convert(varchar,@power_tree_key) 
end  

set @where += ' and power_key '+ @type +' (select power_key from y_role_power where role_key = '+convert(varchar,@role_key)+')'

set @sql = 'select power_key,power_name from y_power where 1=1 {where} '
set @sql =replace(@sql,'{where}',@where)

exec(@sql)
